#!/usr/bin/env node

const http = require('http');
      //log  = console.log;

const html = `
  <!DOCTYPE html>
  <html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>登陆页面</title>
  </head>
    <body>
      <form action="">
        <label >用户名:</label>
        <input type="text" name="username">
        <br>
        <label >密码:</label>
        <input type="password" name="password">
        <br>
        <input type="button" value="登录">
      </form>
    </body>
  </html>`;

http.createServer((req, res) =>{
  //status code
  //jeader,txt/html 
  
  if(res.url !== '/'){
    res.statusCode = 404;
    res.setHeader('Content-type','text/html');
    res.end('<h1>Not Found!</h1>');
    return;
  }

  res.writeHead(200,{
   'Content-type':'text/html',
   'Content-length':Buffer.byteLength(html)
  })
  //res.statusCode = 200;
  //res.setHeader('Content-type','text/html');
  //res.setHeader('Content-length',Buffer.byteLength(html));
  res.end(html);

}).listen(8080);
